/*
 * i2c-decoder.c
 *
 *  Created on: 2024年4月11日
 *      Author: NI
 */
#include <errno.h>
#include "i2c-platfrom.h"


static int fd;
static uint8_t decoder_addr;

int i2c_decoder_init(char * path, uint8_t addr){
	decoder_addr = addr;
	fd = capture_i2c_open(path);
	if(fd < 0){
		return EIO;
	}
	return EOK;
}

int i2c_decoder_deinit(){
	capture_i2c_close(fd);
	return EOK;
}

int i2c_decoder_set_speed(uint32_t speed){
	return capture_i2c_set_speed(fd, speed);
}

int i2c_decoder_rd(uint8_t reg, uint8_t * data){
	return capture_i2c_rd(fd, decoder_addr, reg, data);
}

int i2c_decoder_wr(uint8_t reg, uint8_t value){
	return capture_i2c_wr(fd, decoder_addr, reg, value);
}

int i2c_decoder_dump(uint8_t reg, uint8_t * data, uint32_t len){
	return capture_i2c_dump(fd, decoder_addr, reg, data, len);
}
